package com.fortune.service.impl;

import com.fortune.dao.ReturnDepositDao;
import com.fortune.dto.in.returnDeposit.AddDto;
import com.fortune.dto.in.returnDeposit.EditDto;
import com.fortune.dto.in.returnDeposit.ReturnDepositEditDto;
import com.fortune.service.ReturnDepositService;
import com.fortune.vo.cReturnDeposit.DealerList;
import com.fortune.vo.returnDeposit.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.List;

@Service
public class ReturnDepositServiceImpl implements ReturnDepositService {
    @Autowired
    private ReturnDepositDao returnDepositDao;

    /**
     * 新增工单
     * @param did
     * @param clientId
     * @param orderNo
     * @param crdid
     * @param userId
     * @return
     */
    @Override
    public int addReturnDeposit(String did,String clientId,String crdid,String orderNo,String userId) {
        int addReturnDeposit = returnDepositDao.addReturnDeposit(did, clientId,crdid,orderNo,userId);
        return addReturnDeposit;
    }

    /**
     * 新增退押金工单详情
     * @param did
     * @param clientId
     * @param crdid
     * @param orderNum
     * @param mid
     * @param productId
     * @param productCount
     * @param depositPrice
     * @return
     */
    @Override
    public int addReturnDepositDetails(String did, String clientId, String crdid, int orderNum, String mid, String productId, float productCount, BigDecimal depositPrice) {
        return returnDepositDao.addReturnDepositDetails(did, clientId, crdid, orderNum, mid, productId, productCount, depositPrice);
    }


    /**
     * 编辑工单
     * @param editDto
     * @param did
     * @return
     */
    @Override
    public int editReturnDeposit(EditDto editDto, String did) {
        int editReturnDeposit = returnDepositDao.editReturnDeposit(editDto, did);
        return editReturnDeposit;
    }

    /**
     * 删除工单
     * @param id
     * @return
     */
    @Override
    public int deleteReturnDeposit(String did, String id) {
        int deleteReturnDeposit = returnDepositDao.deleteReturnDeposit(did, id);
        return deleteReturnDeposit;
    }

    /**
     * 未处理工单
     * @param did
     * @param userId
     * @return
     */
    @Override
    public List<ReturnDepositInfo> findReturnDepositInfoByUn(String did, String userId) {
        List<ReturnDepositInfo> findReturnDepositInfoByUn = returnDepositDao.findReturnDepositInfoByUn(did, userId);
        return findReturnDepositInfoByUn;
    }

    /**
     * 已批准工单
     * @param did
     * @param userId
     * @return
     */
    @Override
    public List<ReturnDepositInfo> findReturnDepositInfoByApproved(String did, String userId) {
        List<ReturnDepositInfo> findReturnDepositInfoByApproved = returnDepositDao.findReturnDepositInfoByApproved(did, userId);
        return findReturnDepositInfoByApproved;
    }

    /**
     * 已接货工单
     * @param did
     * @param userId
     * @return
     */
    @Override
    public List<ReturnDepositInfo> findReturnDepositInfoByReceived(String did, String userId) {
        List<ReturnDepositInfo> findReturnDepositInfoByReceived = returnDepositDao.findReturnDepositInfoByReceived(did, userId);
        return findReturnDepositInfoByReceived;
    }

    /**
     * 已完成工单
     * @param did
     * @param userId
     * @return
     */
    @Override
    public List<ReturnDepositInfo> findReturnDepositInfoByCompleted(String did, String userId) {
        List<ReturnDepositInfo> findReturnDepositInfoByCompleted = returnDepositDao.findReturnDepositInfoByCompleted(did, userId);
        return findReturnDepositInfoByCompleted;
    }

    /**
     * 查询已提交的工单详情
     * @param did
     * @param wOrderId
     * @param clientId
     * @return
     */
    @Override
    public DepositDetailsSubmit findDepositDetailsSubmit(String did, String wOrderId, String clientId) {
        return returnDepositDao.findDepositDetailsSubmit(did, wOrderId, clientId);
    }

    /**
     * 查询已批准的工单详情
     * @param did
     * @param wOrderId
     * @param clientId
     * @return
     */
    @Override
    public DepositDetailsApproved findDepositDetailsApproveds(String did, String wOrderId, String clientId) {
        return returnDepositDao.findDepositDetailsApproveds(did, wOrderId, clientId);
    }

    @Override
    public DepositDetailsApproved findDepositDetailsStorage(String did, String wOrderId, String clientId) {
        return returnDepositDao.findDepositDetailsStorage(did, wOrderId, clientId);
    }

    @Override
    public DepositDetailsApproved findDepositDetailsCarry(String did, String wOrderId, String clientId) {
        return returnDepositDao.findDepositDetailsCarry(did, wOrderId, clientId);
    }

    /**
     * 查询客户信息
     * @param clientId
     * @return
     */
    @Override
    public ClientNamePhone findClientNamePhone(String clientId) {
        return returnDepositDao.findClientNamePhone(clientId);
    }

    /**
     *
     * @param did
     * @param clientId
     * @return
     */
    @Override
    public List<DepositProductDetails> findDepositProductDetails(String did, String clientId) {
        return returnDepositDao.findDepositProductDetails(did, clientId);
    }

    @Override
    public List<DepositProductDetails> findDepositProductDetailsByHt(String did) {
        return returnDepositDao.findDepositProductDetailsByHt(did);
    }

    /**
     * 查询当前客户对应的所有经销商列表
     * @param userId
     * @return
     */
    @Override
    public List<DealerList> findDealerList(String userId) {
        return returnDepositDao.findDealerList(userId);
    }

    @Override
    public int delReturnDeposit(String did, ReturnDepositEditDto returnDepositEditDto) {
        return returnDepositDao.delReturnDeposit(did, returnDepositEditDto);
    }
}
